package domain

import (
	"time"
)

type UserMessage struct {
	ID         int64        `json:"id"`
	SenderID   *int64       `json:"-"`
	ReceiverID *int64       `json:"-"`
	ParentID   *int64       `json:"-"`
	Sender     *User        `json:"sender" gorm:"foreignKey:SenderID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Receiver   *User        `json:"receiver" gorm:"foreignKey:ReceiverID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Parent     *UserMessage `json:"parent" gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Message    string       `json:"message" gorm:"not null"`
	CreatedAt  time.Time    `json:"created_at" `
	UpdatedAt  int64        `json:"updated_at" `
}

type UserMessageDTO struct {
	ID         int64           `json:"id"`
	SenderID   *int64          `json:"-"`
	ReceiverID *int64          `json:"-"`
	ParentID   *int64          `json:"-"`
	Sender     *UserDTO        `json:"sender" gorm:"foreignKey:SenderID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Receiver   *UserDTO        `json:"receiver" gorm:"foreignKey:ReceiverID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Parent     *UserMessageDTO `json:"parent" gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Message    string          `json:"message" gorm:"not null"`
	CreatedAt  time.Time       `json:"created_at" `
	UpdatedAt  int64           `json:"updated_at" `
}
